import { CopyInfoPanelBase } from "../CopyInfoPanelBase";
import { Language } from "../../../../../extend/language/Language";
import { SFireMonsterCopyInfo } from "../../../../../Message/Public/SFireMonsterCopyInfo";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { AutoLayoutTextContainer } from "../../../../common/text/AutoLayoutTextContainer";
import { ImagesConst } from "../../../resource/ImagesConst";
import { PageItemRenderer } from "../../common/renderers/PageItemRenderer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { BossConfig } from "../../../resource/BossConfig";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { SecTimerView } from "../../common/SecTimerView";
type int = number;
//class Lv88CopyInfoPanel
    
    export  class Lv88CopyInfoPanel extends CopyInfoPanelBase
    {
        constructor(arg1: Array<any>, arg2: Array<any>, arg3: string=null, arg4: string="MagicTowerInfoButtonBg")
        {
            this._tips = Language.getString(80602);
            if (arg3 != null) 
            {
                this._tips = arg3;
            }
            this._killBossCodes = arg1;
            this._rewardCodes = arg2;
            super(arg4);
            this.title = Language.getString(80605);
            return;
        }

        public updateInfo(arg1: SFireMonsterCopyInfo): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this.killBossNum = arg1.killBossNum;
            this.leftSeconds = arg1.remainTime;
            return;
        }

        public set killBossNum(arg1: int)
        {
            this._killedBossNum = arg1;
            this.updateKilledBossShow();
            return;
        }

        public set leftSeconds(arg1: int)
        {
            this._leftTime.setLeftTime(arg1);
            this.updateLeftTimeColor(arg1);
            if (this._timerId > 300) 
            {
                if (this._timerId > 0) 
                {
                    flash.utils.clearTimeout(this._timerId);
                }
                this._timerId = flash.utils.setTimeout(this.atLast300Seconds, arg1 - 300);
            }
            return;
        }

        /* internal  */atLast300Seconds(): void
        {
            this.updateLeftTimeColor(0);
            return;
        }

        /* internal  */updateLeftTimeColor(arg1: int): void
        {
            if (arg1 < 300) 
            {
                this._leftTime.textColor = 16711680;
            }
            else 
            {
                this._leftTime.textColor = 65280;
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            super.createChildren();
            DisplayUtil.removeMe(_bg);
            _bg = new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(260, 320, false, 0));
            _bg.y = 22;
            _bg.alpha = 0.45;
            _moveSp.addChild(_bg);
            _moveSp.addChild(_bodySp);
            ObjCreate.createGTextField("<font color=\'#ffff00\'>" + Language.getString(90226) + "</font>", 12, 8, 200, 20, _bodySp, null, true);
            var loc2=GlobalStyle.textFormat1;
            loc2.color = 16711680;
            loc2.size = 25;
            loc2.bold = true;
            this._leftTime = ObjCreate.createSecTimeView("hh: mm: ss", 50, 27, 200, 28, _bodySp, loc2);
            this._leftTime.filters = [FilterConst.glowFilter];
            loc2 = GlobalStyle.textFormat2;
            loc2.color = 16776960;
            loc2.bold = true;
            loc1 = ObjCreate.createGTextField(Language.getString(69707), 12, 60, 200, 20, _bodySp, loc2);
            this._txtKillBoss = new AutoLayoutTextContainer();
            this._txtKillBoss.x = 50;
            this._txtKillBoss.y = 80;
            this._txtKillBoss.verticalGap = -2;
            _bodySp.addChild(this._txtKillBoss);
            this.updateKilledBossShow();
            var loc3=this._txtKillBoss.y + this._killBossCodes.length * 16 + 12;
            ObjCreate.createGTextField(Language.getString(51110), 12, loc3, 200, 20, _bodySp, GlobalStyle.textFormat6);
            loc2 = GlobalStyle.textFormat1;
            loc2.leading = 3;
            loc1 = ObjCreate.createAutoSizeGTextFiled("", 12, loc3 + 15, 234, _bodySp);
            loc1.defaultTextFormat = loc2;
            loc1.multiline = true;
            loc1.wordWrap = true;
            loc1.htmlText = this._tips;
            ObjCreate.createBg(10, loc1.y + loc1.height + 2, 240, 2, _bodySp, ImagesConst.SplitLine);
            loc3 = loc1.y + loc1.height + 10;
            ObjCreate.createGTextField(Language.getString(60458), 12, loc3, 200, 20, _bodySp, GlobalStyle.textFormat6);
            loc3 = loc3 + 18;
            this._list = ObjCreate.createTileList(12, loc3, 250, 100, _bodySp);
            this._list.setStyle("cellRenderer", PageItemRenderer);
            this._list.columnWidth = 40;
            this._list.rowHeight = 45;
            var loc4=new DataProvider();
            var loc5=0;
            while (loc5 < this._rewardCodes.length) 
            {
                loc4.addItem(int(this._rewardCodes[loc5]));
                ++loc5;
            }
            this._list.dataProvider = loc4;
            this._list.drawNow();
            return;
        }

        /* internal  */updateKilledBossShow(): void
        {
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc1=0;
            while (loc1 < this._killBossCodes.length) 
            {
                loc2 = this._killBossCodes[loc1];
                loc3 = this._txtKillBoss.getTextByIndex(loc1);
                if (loc3 == null) 
                {
                    loc3 = this._txtKillBoss.addNewText();
                }
                if ((loc4 = BossConfig.instance.getInfoByName(loc2)) != null) 
                {
                    loc5 = Language.getStringByParam(60422, loc4.name);
                    if (loc1 >= this._killedBossNum) 
                    {
                        loc3.textColor = GlobalStyle.color1Uint;
                        loc3.text = loc5 + "(0/1)";
                    }
                    else 
                    {
                        loc3.textColor = 65280;
                        loc3.text = loc5 + "(1/1)";
                    }
                }
                ++loc1;
            }
            return;
        }

        /* internal */ /* var */_killBossCodes: Array<any>;

        /* internal */ /* var */_killedBossNum: int=0;

        /* internal */ /* var */_rewardCodes: Array<any>;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_leftTime: SecTimerView;

        /* internal */ /* var */_txtKillBoss: AutoLayoutTextContainer;

        /* internal */ /* var */_tips: string;

        /* internal */ /* var */_timerId: uint;
    }
